home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Just Call Me Internet
/
Just Call Me Internet.iso
/
prog
/
atari
/
c
/
snz128s
/
src
/
lsi.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-04-13
|
5KB
|
180 lines
/*
SNEWS 2.0
Locical Snews Indexer
Copyright (C) 1993 RJB Communications
rjb@sound.demon.co.uk
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 1, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
See the file COPYING, which contains a copy of the GNU General
Public License.
Atari version ported by Graham Judd - gjudd@siward.demon.co.uk
*/
/*---------------------------- Source Control ------------------------------*/
/*
* $Id: LSI.C,v 1.2 1994/02/05 18:48:42 gbj Exp user $
*/
/**************************************************************************
* 01 Jun 93 1.1 MSM Header added *
* Snews 2.0 *
***************************************************************************/
#include <io.h>
#include <stdio.h>
#include <stdlib.h>
#include <dos.h>
#ifdef ATARI
# include <errno.h>
# define clrscr() printf("\033E")
#else
# include <dir.h>
#endif
#include <string.h>
#include <fcntl.h>
#include <conio.h>
FILE *fidx;
FILE *fact;
FILE *ftmp;
void byebye(char whassup[50])
{
printf("*ERROR* : \"%s\" : %s\n", whassup, strerror(errno));
exit(0);
}
int main()
{
int ax, ay;
long int groups, missing, changes, messages;
char fname[128], fname2[128];
char actgp[128], actcode[12], first[12], last[12];
char actline[200], newline[200], idxline[256], gpidx[128];
char *Title0 = "-------------------------------------------------------------------------------\n";
char *Title1 = " * L * S * I *\n";
char *Title2 = " Logical Snews Indexer --- Version 1.1 (930411)\n";
char *Title3 = " (c) RJB Communications ----- rjb@sound.demon.co.uk\n";
char *Title4 = " Voice [+44](0)932-253131 ------- BBS [+44](0)932-252323\n";
ax = ay = groups = missing = changes = messages = 0;
clrscr();
printf("%s%s%s%s%s", Title1, Title2, Title3, Title4, Title0);
if (!(getenv("SNEWS"))) {
printf("\nYou must have the SNEWS environment variable defined,\n");
printf(" e.g. set SNEWS=c:\\nos\\snews\n\n");
printf("The newsbase directory should be off this,\n");
printf(" i.e. c:\\nos\\snews\\newsbase\n");
exit(1);
}
sprintf(fname, "%s\\active", getenv("SNEWS"));
if ((fact = fopen(fname, "r")) == NULL)
byebye("ACTIVE file");
sprintf(fname, "%s\\active.tmp", getenv("SNEWS"));
if ((ftmp = fopen(fname, "w")) == NULL)
byebye("ACTIVE.TMP file");
strset(actline, 0);
fgets(actline, 199, fact);
while ((!feof(fact)) && (strlen(actline))) {
strcpy(first, "00000000");
strcpy(last, "00000000");
strset(actgp, 0);
strset(gpidx, 0);
for (ax = 0, ay = 0; (actline[ax] != ' '); actgp[ay++] = actline[ax++]);
actgp[ay] = 0;
for (ax++, ay = 0; (actline[ax] != ' '); actcode[ay++] = actline[ax++]);
actcode[ay] = 0;
sprintf(gpidx, "%s\\newsbase\\%s.idx", getenv("SNEWS"), actcode);
if ((fidx = fopen(gpidx, "rb")) == NULL) {
printf("! %s (%s) doesn't exist !\n", actgp, actcode);
missing++;
}
else {
fgets(idxline, 255, fidx);
if (strlen(idxline)) {
for (ax = 9, ay = 0; ax < 17; first[ay++] = idxline[ax++]);
first[ay] = 0;
}
strcpy(last, first);
while (!feof(fidx)) {
strset(idxline, 0);
fgets(idxline, 255, fidx);
if (strlen(idxline)) {
for (ax = 9, ay = 0; ax < 17; last[ay++] = idxline[ax++]);
last[ay] = 0;
messages++;
}
}
}
fclose(fidx);
if (atoi(first))
sprintf(first, "%08d", (atoi(first)) - 1);
sprintf(newline, "%s %s %s %s y\n", actgp, actcode, first, last);
newline[strlen(newline)] = 0;
if (strcmp(actline, newline) == 0) {
printf(" %s", newline);
}
else {
printf("> %s", newline);
changes++;
}
fprintf(ftmp, "%s", newline);
groups++;
strset(actline, 0);
fgets(actline, 199, fact);
}
printf("%s%s%s%s%s\n", Title0, Title1, Title2, Title3, Title4);
printf("%12ld Groups\n", groups);
printf("%12ld Missing Groups\n", missing);
printf("%12ld Altered Indexes\n", changes);
printf("%12ld Messages\n", messages);
printf("%s\n", Title0);
fclose(fact);
fclose(ftmp);
sprintf(fname, "%s\\active.old", getenv("SNEWS"));
remove(fname);
sprintf(fname, "%s\\active", getenv("SNEWS"));
sprintf(fname2, "%s\\active.old", getenv("SNEWS"));
rename(fname, fname2);
sprintf(fname, "%s\\active.tmp", getenv("SNEWS"));
sprintf(fname2, "%s\\active", getenv("SNEWS"));
rename(fname, fname2);
return (0);
}